package cn.net.lwj.services.impl;

import cn.net.lwj.dao.DemoUserDao;
import cn.net.lwj.dao.JdbcTool;
import cn.net.lwj.entity.Note;
import cn.net.lwj.entity.User;
import cn.net.lwj.services.DemoService;
import java.util.List;
import javax.annotation.Resource;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(isolation = Isolation.READ_COMMITTED)
public class DemoServiceImpl extends BaseServiceImpl implements DemoService {

    @Autowired
    private JdbcTool jdbcTool;

    @Resource
    private DemoUserDao demoUserDao;


    public JSONObject test() throws Exception {
        String sql = "SELECT * FROM `user_t`;";
        JSONObject jsonObject=new JSONObject();
        try {
            List list = jdbcTool.queryForList(sql);
            log.info("-----list" + list);
            log.info("=====================================");
            User user = demoUserDao.findUserById("1");
            log.info("user:" + user);
            jsonObject.put("list", list);
            List<Note> mybatislist = demoUserDao.findNotes("1");
            jsonObject.put("mybatislist", mybatislist);
            log.info("mybatislist:" + mybatislist);
            //List<Note> mybatislist1 = demoUserDao.findNotes1("1");
            //List<Note> mybatislist2 = demoUserDao.findNotes2("1");
            //log.info("mybatislist1:" + mybatislist1);
            //log.info("mybatislist2:" + mybatislist2);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonObject;

    }

}
